home *** CD-ROM | disk | FTP | other *** search
/ Info-Mac 4 / Info_Mac IV CD-ROM (Pacific HiTech Inc.)(August 1994).iso / Science / RLaB / examples / ode_examples.r < prev    next >
Text File  |  1994-04-25  |  645b  |  37 lines

  1. //
  2. //  Integrate the Van der Pol equation
  3. //
  4.  
  5. vdpol = function ( t , x ) 
  6. {
  7.   local(xdot);
  8.  
  9.   xdot[1;1] = x[1] * (1 - x[2]^2) - x[2];
  10.   xdot[2;1] = x[1];
  11.   return xdot;
  12. };
  13.  
  14. vdpol_out = function ( t , x )
  15. {
  16.   return [t; x; 2*x];
  17. };
  18.  
  19. // system( "/usr/ucb/ps -aux | grep rlab" );
  20. t0 = 0;
  21. tf = 20;
  22. x0 = [0; 0.25];
  23. tic();
  24. //out = ode23( vdpol, t0, tf, x0, vdpol_out);
  25. //rfile ode78
  26. //out = ode78( vdpol, t0, tf, x0, vdpol_out );
  27. rfile ode4
  28. out = ode4( vdpol, t0, tf, x0, vdpol_out );
  29. printf(" Elapsed integration time: %i\n", toc() );
  30.  
  31. plgrid ();
  32. ptitle ( "RLaB ODE Example (vdpol)" );
  33. xlabel ( "Time (seconds)" );
  34. ylabel ( "States" );
  35.  
  36. plot( out );
  37.